home *** CD-ROM | disk | FTP | other *** search
/ Champak 43 / Vol 43.iso / games / superdog.swf / scripts / DefineSprite_1784 / frame_2 / DoAction.as
Encoding:
Text File  |  2007-06-25  |  10.1 KB  |  502 lines

  1. function times()
  2. {
  3.    if(tNum++ >= 40)
  4.    {
  5.       gameTime -= 1;
  6.       tNum = 0;
  7.    }
  8.    if(gameTime <= 0)
  9.    {
  10.       manHp = 0;
  11.       gameTime = 200;
  12.    }
  13. }
  14. function superPower()
  15. {
  16.    if(green <= 0)
  17.    {
  18.       powerTime.gotoAndStop("str");
  19.       ability = "power";
  20.       green = 20;
  21.       man.prs._visible = true;
  22.       powIco._alpha = 100;
  23.       pTime = 0;
  24.       tMax = 20;
  25.       flyNow = false;
  26.       spdNow = false;
  27.       movspd = 5;
  28.    }
  29.    else if(blue <= 0)
  30.    {
  31.       powerTime.gotoAndStop("fly");
  32.       ability = "fly";
  33.       blue = 20;
  34.       flyIco._alpha = 100;
  35.       pTime = 0;
  36.       tMax = 10;
  37.       flyNow = false;
  38.       spdNow = false;
  39.       movspd = 5;
  40.    }
  41.    else if(red <= 0)
  42.    {
  43.       powerTime.gotoAndStop("eye");
  44.       ability = "eye";
  45.       red = 20;
  46.       man.prs._visible = true;
  47.       eyeIco._alpha = 100;
  48.       pTime = 0;
  49.       tMax = 10;
  50.       flyNow = false;
  51.       spdNow = false;
  52.       movspd = 5;
  53.    }
  54.    else if(yellow <= 0)
  55.    {
  56.       powerTime.gotoAndStop("spd");
  57.       ability = "speed";
  58.       yellow = 20;
  59.       speIco._alpha = 100;
  60.       pTime = 0;
  61.       tMax = 10;
  62.       flyNow = false;
  63.       spdNow = false;
  64.       movspd = 5;
  65.    }
  66.    if(purple <= 0)
  67.    {
  68.       powerTime.gotoAndStop("bre");
  69.       ability = "breath";
  70.       purple = 20;
  71.       man.prs._visible = true;
  72.       breIco._alpha = 100;
  73.       pTime = 0;
  74.       tMax = 10;
  75.       flyNow = false;
  76.       spdNow = false;
  77.       movspd = 5;
  78.    }
  79. }
  80. function powTimeLeft()
  81. {
  82.    if(tMax > 3)
  83.    {
  84.       dog_blink(8);
  85.    }
  86.    else
  87.    {
  88.       dog_blink(4);
  89.    }
  90.    pTime++;
  91.    if(pTime >= 30)
  92.    {
  93.       pTime = 0;
  94.       tMax -= 1;
  95.    }
  96.    if(tMax == 3 and land.flywar == true)
  97.    {
  98.       land.play();
  99.    }
  100.    if(tMax == 7 and land.flywar == true and land.boss.behit == false)
  101.    {
  102.       land.boss.gotoAndPlay("σÅæσ░ä");
  103.       land.boss.shakeNow = false;
  104.    }
  105.    if(tMax <= 0)
  106.    {
  107.       a = 0;
  108.       pTime = 0;
  109.       powIco._alpha = 50;
  110.       eyeIco._alpha = 50;
  111.       speIco._alpha = 50;
  112.       breIco._alpha = 50;
  113.       flyIco._alpha = 50;
  114.       man.xiaoguo.gotoAndStop(1);
  115.       powerTime.gotoAndStop(1);
  116.       man.prs._visible = false;
  117.       movlock = false;
  118.       ability = null;
  119.       man.breathed = false;
  120.       movspd = 5;
  121.    }
  122. }
  123. function inairNow()
  124. {
  125.    if(inAir == true)
  126.    {
  127.       if(yinc < 15)
  128.       {
  129.          yinc += g;
  130.       }
  131.       if(yinc > 0)
  132.       {
  133.          if(man._y >= 600)
  134.          {
  135.             manHp = 0;
  136.          }
  137.          if(land._y > 0 && man._y >= 300 && nojump == false)
  138.          {
  139.             land._y -= yinc;
  140.             enemy._y -= yinc;
  141.             bg._y -= yinc;
  142.             if(land._y <= 0)
  143.             {
  144.                land._y = 0;
  145.             }
  146.             if(enemy._y <= 0)
  147.             {
  148.                enemy._y = 0;
  149.             }
  150.             if(bg._y <= 0)
  151.             {
  152.                bg._y = 0;
  153.             }
  154.          }
  155.          else
  156.          {
  157.             man._y += yinc;
  158.          }
  159.       }
  160.       if(yinc < 0)
  161.       {
  162.          if(man._y < 300 && nojump == false)
  163.          {
  164.             land._y -= yinc;
  165.             enemy._y -= yinc;
  166.             bg._y -= yinc;
  167.          }
  168.          else
  169.          {
  170.             man._y += yinc;
  171.          }
  172.       }
  173.       var _loc3_ = 0;
  174.       while(_loc3_ < land_array.length)
  175.       {
  176.          landObject = this.land[land_array[_loc3_]];
  177.          var _loc4_ = landObject.getBounds(_root).yMin;
  178.          if(man.fk.hitTest(landObject) and landObject.noHit != true)
  179.          {
  180.             if(landObject.ice == true and man.fk.hitTest(landObject.fk) and yinc >= -2)
  181.             {
  182.                ice = true;
  183.             }
  184.             else
  185.             {
  186.                ice = false;
  187.             }
  188.             if(man._y - yinc < _loc4_)
  189.             {
  190.                inAir = false;
  191.                canjump = true;
  192.                man._y = _loc4_;
  193.                if(spdNow == false and movlock == false)
  194.                {
  195.                   man.gotoAndStop("τ½Ö");
  196.                   if(man.finish == true)
  197.                   {
  198.                      end = true;
  199.                      movlock = true;
  200.                      man.gotoAndPlay("finish");
  201.                   }
  202.                }
  203.                else if(spdNow == true and movlock == false)
  204.                {
  205.                   man.gotoAndStop("σèáΘǃ");
  206.                }
  207.                yinc = 0;
  208.                break;
  209.             }
  210.          }
  211.          _loc3_ = _loc3_ + 1;
  212.       }
  213.    }
  214.    else if(!this.man.fk.hitTest(landObject))
  215.    {
  216.       yinc = 1;
  217.       inAir = true;
  218.    }
  219. }
  220. function jump_Ob()
  221. {
  222.    if(jLock == false)
  223.    {
  224.       if(Key.isDown(38) or Key.isDown(65))
  225.       {
  226.          if(canjump == true and movlock == false and inAir == false)
  227.          {
  228.             man.gotoAndStop("Φ╖│");
  229.             js.start();
  230.             inAir = true;
  231.             if(spdNow == false)
  232.             {
  233.                yinc = -15;
  234.             }
  235.             else
  236.             {
  237.                yinc = -18;
  238.             }
  239.             canjump = false;
  240.          }
  241.       }
  242.    }
  243.    if(Key.isDown(38) or Key.isDown(65))
  244.    {
  245.       jLock = true;
  246.    }
  247.    else
  248.    {
  249.       jLock = false;
  250.    }
  251. }
  252. function moveFunc()
  253. {
  254.    if(ice == false)
  255.    {
  256.       icespdl = 0;
  257.       icespdr = 0;
  258.       if(man.lDown == false and man.rDown == false)
  259.       {
  260.          moveL = false;
  261.          moveR = false;
  262.       }
  263.       if(man.lDown == true)
  264.       {
  265.          if(land._x < 0 and man._x <= 290)
  266.          {
  267.             land._x += movspd;
  268.             bg._x += movspd / 2;
  269.             moveR = true;
  270.             moveL = false;
  271.          }
  272.          else if(man._x > 0)
  273.          {
  274.             man._x -= movspd;
  275.          }
  276.       }
  277.       else if(man.rDown == true)
  278.       {
  279.          if(man._x >= 290 and land._x > 580 - land._width + 50 and scrlock == false)
  280.          {
  281.             land._x -= movspd;
  282.             bg._x -= movspd / 2;
  283.             moveL = true;
  284.             moveR = false;
  285.          }
  286.          else if(man._x < 550)
  287.          {
  288.             man._x += movspd;
  289.          }
  290.       }
  291.    }
  292.    else
  293.    {
  294.       if(man.lDown == true and icespdl < 10)
  295.       {
  296.          icespdl += 1;
  297.       }
  298.       else if(man.rDown == true and icespdr < 10)
  299.       {
  300.          icespdr += 1;
  301.       }
  302.       if(icespdl > 0)
  303.       {
  304.          icespdl -= 0.2;
  305.       }
  306.       if(icespdr > 0)
  307.       {
  308.          icespdr -= 0.2;
  309.       }
  310.       if(icespdl > icespdr)
  311.       {
  312.          if(land._x < 0 and man._x <= 290)
  313.          {
  314.             land._x += icespdl;
  315.             land._x -= icespdr;
  316.             bg._x += icespdl / 2;
  317.             bg._x -= icespdr / 2;
  318.          }
  319.          else if(man._x > 0)
  320.          {
  321.             man._x -= icespdl;
  322.             man._x += icespdr;
  323.          }
  324.       }
  325.       else if(man._x >= 290 and land._x > 580 - land._width + 50 and scrlock == false)
  326.       {
  327.          land._x += icespdl;
  328.          land._x -= icespdr;
  329.          bg._x += icespdl / 2;
  330.          bg._x -= icespdr / 2;
  331.       }
  332.       else if(man._x < 550)
  333.       {
  334.          man._x += icespdr;
  335.          man._x -= icespdl;
  336.       }
  337.    }
  338.    var _loc3_ = 0;
  339.    while(_loc3_ < land_array.length)
  340.    {
  341.       var _loc2_ = this.land[land_array[_loc3_]];
  342.       if(man.fk.hitTest(_loc2_) and man.dDown == true)
  343.       {
  344.          man._y -= 5;
  345.       }
  346.       if(man.qfk.hitTest(_loc2_) and _loc2_.noWalk == true)
  347.       {
  348.          if(man.rDown == true)
  349.          {
  350.             land._x += movspd;
  351.             bg._x += movspd / 2;
  352.             moveR = true;
  353.          }
  354.          if(man.lDown == true)
  355.          {
  356.             land._x -= movspd;
  357.             bg._x -= movspd / 2;
  358.             moveL = true;
  359.          }
  360.       }
  361.       _loc3_ = _loc3_ + 1;
  362.    }
  363. }
  364. function dog_blink(a_time)
  365. {
  366.    if(a_i <= a_time)
  367.    {
  368.       a_i++;
  369.    }
  370.    if(a_i >= a_time and a_sta == true)
  371.    {
  372.       a = 150;
  373.       a_i = 0;
  374.       a_sta = false;
  375.    }
  376.    if(a_i >= a_time and a_sta == false)
  377.    {
  378.       a_sta = true;
  379.       a = 0;
  380.       a_i = 0;
  381.    }
  382. }
  383. var pauses = false;
  384. var manHp = 3;
  385. var maxHp = 3;
  386. var coHp = 0;
  387. var life = 3;
  388. var movspd = 5;
  389. var gameTime = 200;
  390. var score = 0;
  391. var nowLevel = "level111";
  392. var green = 20;
  393. var blue = 20;
  394. var red = 20;
  395. var yellow = 20;
  396. var purple = 20;
  397. var scrlock = false;
  398. var end = false;
  399. bluNum.gotoAndStop(2);
  400. bluIco._alpha = 50;
  401. redNum.gotoAndStop(2);
  402. redIco._alpha = 50;
  403. yelNum.gotoAndStop(2);
  404. yelIco._alpha = 50;
  405. purNum.gotoAndStop(2);
  406. purIco._alpha = 50;
  407. var ability = null;
  408. var flyNow = false;
  409. var spdNow = false;
  410. var land_array = [];
  411. var enemy_array = [];
  412. var item_array = [];
  413. var dep = 1;
  414. var canjump = true;
  415. var movlock = false;
  416. var inAir = false;
  417. var yinc = 0;
  418. var nojump = true;
  419. var g = 1;
  420. var pLock = false;
  421. onEnterFrame = function()
  422. {
  423.    if(dep >= 80)
  424.    {
  425.       dep = 0;
  426.    }
  427.    if(coHp == 2)
  428.    {
  429.       maxHp = 4;
  430.    }
  431.    else if(coHp == 4)
  432.    {
  433.       maxHp = 5;
  434.    }
  435.    if(end == false)
  436.    {
  437.       if(Key.isDown(80) and pLock == false)
  438.       {
  439.          if(_parent.menus._visible == false and pauses == false)
  440.          {
  441.             _parent.menus._visible = true;
  442.             pauses = true;
  443.          }
  444.          else
  445.          {
  446.             _parent.menus._visible = false;
  447.             pauses = false;
  448.          }
  449.       }
  450.    }
  451.    if(pauses == false and end == false)
  452.    {
  453.       if(flyNow == true)
  454.       {
  455.          ice = false;
  456.       }
  457.       times();
  458.       if(flyNow == false or man.stopFly == true)
  459.       {
  460.          inairNow();
  461.       }
  462.       if(ability != null)
  463.       {
  464.          powTimeLeft();
  465.       }
  466.       if(movlock == false and end == false)
  467.       {
  468.          jump_Ob();
  469.          superPower();
  470.          moveFunc();
  471.       }
  472.    }
  473.    if(Key.isDown(80))
  474.    {
  475.       pLock = true;
  476.    }
  477.    else
  478.    {
  479.       pLock = false;
  480.    }
  481. };
  482. var icespdl = 0;
  483. var icespdr = 0;
  484. var ice = false;
  485. var tNum = 0;
  486. var pTime = 0;
  487. var tMax;
  488. var jLock = false;
  489. MovieClip.prototype.setBrightOffset = function(offset)
  490. {
  491.    var This = new Color(this);
  492.    var trans = This.getTransform();
  493.    with(trans)
  494.    {
  495.       rb = gb = bb = offset;
  496.    }
  497.    This.setTransform(trans);
  498. };
  499. var a = 0;
  500. var a_i = 0;
  501. var a_sta = true;
  502.